%
% sphinx.sty
%
% Adapted from the old python.sty, mostly written by Fred Drake,
% by Georg Brandl.
%

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sphinx}[2021/01/27 v4.0.0 LaTeX package (Sphinx markup)]

% provides \ltx@ifundefined
% (many packages load ltxcmds: graphicx does for pdftex and lualatex but
% not xelatex, and anyhow kvoptions does, but it may be needed in future to
% use \sphinxdeprecationwarning earlier, and it needs \ltx@ifundefined)
\RequirePackage{ltxcmds}

%% for deprecation warnings
\newcommand\sphinxdeprecationwarning[4]{% #1 the deprecated macro or name,
% #2 = when deprecated, #3 = when removed, #4 = additional info
  \edef\spx@tempa{\detokenize{#1}}%
  \ltx@ifundefined{sphinx_depr_\spx@tempa}{%
     \global\expandafter\let\csname sphinx_depr_\spx@tempa\endcsname\spx@tempa
     \expandafter\AtEndDocument\expandafter{\expandafter\let\expandafter
         \sphinxdeprecatedmacro\csname sphinx_depr_\spx@tempa\endcsname
         \PackageWarningNoLine{sphinx}{^^J**** SPHINX DEPRECATION WARNING:^^J
         \sphinxdeprecatedmacro^^J
         \@spaces- is deprecated at Sphinx #2^^J
         \@spaces- and removed at Sphinx #3.^^J
         #4^^J****}}%
  }{% warning already emitted (at end of latex log), don't repeat
  }}


%% PACKAGES
%
% we delay handling of options to after having loaded packages, because
% of the need to use \definecolor.
\input{sphinxlatexrequirepackages.sty}


%% PYGMENTS
% stylesheet for highlighting with pygments
\RequirePackage{sphinxhighlight}
% fix baseline increase from Pygments latex formatter in case of error tokens
% and keep \fboxsep's scope local via added braces
\def\PYG@tok@err{%
    \def\PYG@bc##1{{\setlength{\fboxsep}{-\fboxrule}%
                    \fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}%
}
\def\PYG@tok@cs{%
    \def\PYG@tc##1{\textcolor[rgb]{0.25,0.50,0.56}{##1}}%
    \def\PYG@bc##1{{\setlength{\fboxsep}{0pt}%
                    \colorbox[rgb]{1.00,0.94,0.94}{\strut ##1}}}%
}%


%% OPTION HANDLING
%
\input{sphinxlatexoptionhandling.sty}


%% LISTS
%
\input{sphinxlatexmisclists.sty}


%% INDEX, BIBLIOGRAPHY, APPENDIX, TABLE OF CONTENTS
%
\input{sphinxlatexenvindbibtoc.sty}


%% FIXME STUFF
%
\input{sphinxlatexmiscfixme.sty}


%% PAGE STYLING
%
\input{sphinxlatexstylepage.sty}


%% TITLES
%
\input{sphinxlatexstyleheadings.sty}


%% GRAPHICS
%
\input{sphinxlatexgraphics.sty}


%% CITATIONS
%
\protected\def\sphinxcite{\cite}


%% FOOTNOTES
%
% Support large numbered footnotes in minipage
% But now obsolete due to systematic use of \savenotes/\spewnotes
% when minipages are in use in the various macro definitions next.
\def\thempfootnote{\arabic{mpfootnote}}


%% NUMBERING OF FIGURES, TABLES, AND LITERAL BLOCKS
%
\input{sphinxlatexmiscnumbering.sty}


%% LITERAL BLOCKS
%
\input{sphinxlatexenvliteral.sty}


%% TOPIC AND CONTENTS BOXES
%
\input{sphinxlatexenvshadowbox.sty}


%% NOTICES AND ADMONITIONS
%
\input{sphinxlatexenvadmonitions.sty}


%% PYTHON DOCS MACROS AND ENVIRONMENTS
%
\input{sphinxlatexenvdocs.sty}


%% TEXT STYLING
%
\input{sphinxlatexstyletext.sty}


\endinput
